---
# tasks file for ansible-ansible-openshift-ansible
#

- name: Install required packages
  package: name="{{ item }}" state=present
  with_items:
    - ansible
    - git
    - pyOpenSSL

- name: git clone the openshift-ansible repo
  git:
    repo: "https://github.com/openshift/openshift-ansible.git"
    dest: "{{ openshift_ansible_path }}"
    version: "{{ openshift_ansible_version }}"
  when: env == "production"

# Need to use my fork in stage until these are merged upstream and backported
# to the release-3.6 branch
#
#   https://github.com/openshift/openshift-ansible/pull/5101
#   https://github.com/openshift/openshift-ansible/pull/5129
- name: git clone the openshift-ansible repo
  git:
    repo: "https://github.com/maxamillion/openshift-ansible"
    dest: "{{ openshift_ansible_path }}"
    version: "{{ openshift_ansible_version }}"
  when: env == "staging"

- name: generate the inventory file
  template:
    src: "cluster-inventory.j2"
    dest: "{{ openshift_ansible_path }}/{{ cluster_inventory_filename }}"

- name: run ansible
  shell: "ansible-playbook {{ openshift_ansible_playbook }} -i {{ cluster_inventory_filename }}"
  args:
    chdir: "{{ openshift_ansible_path }}"
  register: run_ansible_out

- name: display run ansible stdout_lines
  debug:
    var: run_ansible_out.stdout_lines

- name: display run ansible stderr
  debug:
    var: run_ansible_out.stderr


